using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using SftTreeLib70;
using AxSftTreeLib70;
using Softelvdm.OLEConvert;

namespace ContentWindows {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e) {

            String path = System.IO.Path.GetDirectoryName(System.IO.Path.GetDirectoryName(System.IO.Path.GetDirectoryName(Application.ExecutablePath)));
            // Flash
            axShockwaveFlash1.Movie = path + "\\header.swf";
            axSftTree1.get_Item(3).get_Cell(1).AttachContentWindow((int) axShockwaveFlash1.Handle, SftTreeContentWindowStyleConstants.contentWindowSftTreeKeepSize);
            axSftTree1.get_Item(3).get_Cell(1).Text = "";

            // Windows Media Player
            axWindowsMediaPlayer1.URL = path + "\\intermission.wmv";
            axSftTree1.get_Item(4).get_Cell(1).AttachContentWindow((int) axWindowsMediaPlayer1.Handle, SftTreeContentWindowStyleConstants.contentWindowSftTreeKeepSize);
            axSftTree1.get_Item(4).get_Cell(1).Text = "";

            // Web Browser
            webBrowser1.Navigate("http://www.softelvdm.com");
            SftTreeItem Item = axSftTree1.get_Item(5);
            SftTreeCell Cell = Item.get_Cell(1);
            Cell.AttachContentWindow((int)webBrowserPanel.Handle, SftTreeContentWindowStyleConstants.contentWindowSftTreeNone);
            Cell.Text = "";
            Item.MinHeightPix = 300; // always exactly 300 pixels
            Item.MaxHeightPix = 300; // always exactly 300 pixels

            // Form
            Form2 f = new Form2();
            axSftTree1.get_Item(6).get_Cell(1).AttachContentWindow((int)f.Handle, SftTreeContentWindowStyleConstants.contentWindowSftTreeKeepSize);
            axSftTree1.get_Item(6).get_Cell(1).Text = "";

            axSftTree1.RowHeaders.MakeOptimal(); // Make row header width optimal, so text and pictures are not clipped horizontally.
            axSftTree1.ColumnsObj.MakeOptimal(); // Make all columns optimal

            // triple the size of the last column
            axSftTree1.get_Column(1).WidthPix = axSftTree1.get_Column(1).WidthPix * 3;

            axSftTree1.Items.RecalcHorizontalExtent(); // Update horizontal scrollbar

            axSftTree1.Items.Current = 0; // select the first item
            axSftTree1.get_Item(0).Selected = true;

            axSftTree1.Dock = DockStyle.Fill; // Maximize the main window

            this.WindowState = FormWindowState.Maximized;
        }

        private void axSftTree1_ItemExpanded(object sender, _DSftTreeEvents_ItemExpandedEvent e) {
            if (e.itemIndex == 2)
                axWindowsMediaPlayer1.Ctlcontrols.play();
        }

        private void axSftTree1_ItemCollapsed(object sender, _DSftTreeEvents_ItemCollapsedEvent e) {
            if (e.itemIndex == 2)
                axWindowsMediaPlayer1.Ctlcontrols.pause();
        }

        private void axSftTree1_ItemDblClick(object sender, _DSftTreeEvents_ItemDblClickEvent e) {
            if (e.areaType == (short) SftTreeAreaTypeConstants.constSftTreeColumnRes) {
                axSftTree1.get_Column(e.colIndex).MakeOptimal();
            }
        }
    }
}